#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5;
typedef long long LL;
LL a[20];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n;cin>>n;
    while(1){
        LL x=n;
        LL sum=0;
        while(x>0){
            a[++sum]=x%10;
            x/=10;
        }
        bool flag=1;
        for(LL i=1;i<=sum;i++){
            if(a[i]!=0&&n%a[i]!=0){
                    flag=0;
                    break;
            }
        }
        if(flag==1) break;
        else{
            n++;
        }
    }
    cout<<n<<endl;
  }
return 0;
}
